<!DOCTYPE html><html><head>
<title>uri - Tcl Uniform Resource Identifier Management</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'uri.man' by tcllib/doctools with format 'html'
   -->
<!-- uri.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">uri(n) 1.2.7 tcllib &quot;Tcl Uniform Resource Identifier Management&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>uri - URI utilities</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">COMMANDS</a></li>
<li class="doctools_section"><a href="#section3">SCHEMES</a></li>
<li class="doctools_section"><a href="#section4">EXTENDING</a></li>
<li class="doctools_section"><a href="#section5">QUIRK OPTIONS</a>
<ul>
<li class="doctools_subsection"><a href="#subsection1">BACKWARD COMPATIBILITY</a></li>
<li class="doctools_subsection"><a href="#subsection2">NEW DESIGNS</a></li>
<li class="doctools_subsection"><a href="#subsection3">DEFAULT VALUES</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#section6">EXAMPLES</a></li>
<li class="doctools_section"><a href="#section7">CREDITS</a></li>
<li class="doctools_section"><a href="#section8">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.2</b></li>
<li>package require <b class="pkgname">uri <span class="opt">?1.2.7?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">uri::setQuirkOption</b> <i class="arg">option</i> <span class="opt">?<i class="arg">value</i>?</span></a></li>
<li><a href="#2"><b class="cmd">uri::split</b> <i class="arg">url</i> <span class="opt">?<i class="arg">defaultscheme</i>?</span></a></li>
<li><a href="#3"><b class="cmd">uri::join</b> <span class="opt">?<i class="arg">key</i> <i class="arg">value</i>?</span>...</a></li>
<li><a href="#4"><b class="cmd">uri::resolve</b> <i class="arg">base</i> <i class="arg">url</i></a></li>
<li><a href="#5"><b class="cmd">uri::isrelative</b> <i class="arg">url</i></a></li>
<li><a href="#6"><b class="cmd">uri::geturl</b> <i class="arg">url</i> <span class="opt">?<i class="arg">options</i>...?</span></a></li>
<li><a href="#7"><b class="cmd">uri::canonicalize</b> <i class="arg">uri</i></a></li>
<li><a href="#8"><b class="cmd">uri::register</b> <i class="arg">schemeList</i> <i class="arg">script</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>This package does two things.</p>
<p>First, it provides a number of
commands for manipulating URLs/URIs and fetching data specified by
them. For fetching data this package analyses the requested URL/URI and
then dispatches it to the appropriate package (<b class="package"><a href="../../../../index.html#http">http</a></b>, <b class="package"><a href="../ftp/ftp.html">ftp</a></b>, ...) for
actual retrieval.  Currently these commands are defined for the schemes
<i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, <i class="term"><a href="../../../../index.html#mailto">mailto</a></i>, <i class="term"><a href="../../../../index.html#news">news</a></i>,
<i class="term"><a href="../../../../index.html#ldap">ldap</a></i>, <i class="term">ldaps</i> and <i class="term"><a href="../../../../index.html#file">file</a></i>.  The package <b class="package">uri::urn</b> adds scheme <i class="term"><a href="../../../../index.html#urn">urn</a></i>.</p>
<p>Second, it provides regular expressions
for a number of <b class="const">registered</b> URL/URI schemes. Registered
schemes are currently <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, <i class="term"><a href="../../../../index.html#ldap">ldap</a></i>, <i class="term">ldaps</i>, <i class="term"><a href="../../../../index.html#file">file</a></i>,
<i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, <i class="term"><a href="../../../../index.html#gopher">gopher</a></i>, <i class="term"><a href="../../../../index.html#mailto">mailto</a></i>, <i class="term"><a href="../../../../index.html#news">news</a></i>,
<i class="term"><a href="../../../../index.html#wais">wais</a></i> and <i class="term"><a href="../../../../index.html#prospero">prospero</a></i>.  The package <b class="package">uri::urn</b> adds scheme
<i class="term"><a href="../../../../index.html#urn">urn</a></i>.</p>
<p>The commands of the package conform to
RFC 3986 (<a href="https://www.rfc-editor.org/rfc/rfc3986.txt">https://www.rfc-editor.org/rfc/rfc3986.txt</a>),
with the exception of a loophole arising from RFC 1630 and described
in RFC 3986 Sections 5.2.2 and 5.4.2. The loophole allows a relative
URI to include a scheme if it is the same as the scheme of the base
URI against which it is resolved. RFC 3986 recommends avoiding this usage.</p>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">COMMANDS</a></h2>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">uri::setQuirkOption</b> <i class="arg">option</i> <span class="opt">?<i class="arg">value</i>?</span></a></dt>
<dd><p><b class="cmd">uri::setQuirkOption</b> is an accessor command for a number of &quot;quirk options&quot;.
The command has the same semantics as the command <b class="cmd"><a href="../../../../index.html#set">set</a></b>: when called with one argument it reads an existing value; with two arguments it writes a new value.  The value of a &quot;quirk option&quot; is boolean: the value <b class="const">false</b> requests conformance with RFC 3986, while <b class="const">true</b> requests use of the quirk.  See section <span class="sectref"><a href="#section5">QUIRK OPTIONS</a></span> for discussion of the different options and their purpose.</p></dd>
<dt><a name="2"><b class="cmd">uri::split</b> <i class="arg">url</i> <span class="opt">?<i class="arg">defaultscheme</i>?</span></a></dt>
<dd><p><b class="cmd">uri::split</b> takes a <i class="arg">url</i>, decodes it and then returns a
list of key/value pairs suitable for <b class="cmd">array set</b> containing the
constituents of the <i class="arg">url</i>. If the scheme is missing from the <i class="arg">url</i>
it defaults to the value of <i class="arg">defaultscheme</i> if it was specified,
or <i class="term"><a href="../../../../index.html#http">http</a></i> else. Currently the schemes <i class="term"><a href="../../../../index.html#http">http</a></i>,
<i class="term"><a href="../../../../index.html#https">https</a></i>, <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, <i class="term"><a href="../../../../index.html#mailto">mailto</a></i>, <i class="term"><a href="../../../../index.html#news">news</a></i>, <i class="term"><a href="../../../../index.html#ldap">ldap</a></i>, <i class="term">ldaps</i> and
<i class="term"><a href="../../../../index.html#file">file</a></i> are supported by the package itself.
See section <span class="sectref"><a href="#section4">EXTENDING</a></span> on how to expand that range.</p>
<p>The set of constituents of a URL (= the set of keys in the returned
dictionary) is dependent on the scheme of the URL. The only key which
is therefore always present is <b class="const">scheme</b>. For the following
schemes the constituents and their keys are known:</p>
<dl class="doctools_definitions">
<dt>ftp</dt>
<dd><p><b class="const">user</b>, <b class="const">pwd</b>, <b class="const">host</b>, <b class="const">port</b>,
<b class="const">path</b>, <b class="const">type</b>, <b class="const">pbare</b>.  The pbare is optional.</p></dd>
<dt>http(s)</dt>
<dd><p><b class="const">user</b>, <b class="const">pwd</b>, <b class="const">host</b>, <b class="const">port</b>,
<b class="const">path</b>, <b class="const">query</b>, <b class="const">fragment</b>, <b class="const">pbare</b>.  The pbare is optional.</p></dd>
<dt>file</dt>
<dd><p><b class="const">path</b>, <b class="const">host</b>. The host is optional.</p></dd>
<dt>mailto</dt>
<dd><p><b class="const">user</b>, <b class="const">host</b>. The host is optional.</p></dd>
<dt>ldap(s)</dt>
<dd><p><b class="const">host</b>, <b class="const">port</b>, <b class="const">dn</b>, <b class="const">attrs</b>, <b class="const">scope</b>, <b class="const">filter</b>, <b class="const">extensions</b></p></dd>
<dt>news</dt>
<dd><p>Either <b class="const">message-id</b> or <b class="const">newsgroup-name</b>.</p></dd>
</dl>
<p>For discussion of the boolean <b class="const">pbare</b> see options <em>NoInitialSlash</em> and <em>NoExtraKeys</em> in <span class="sectref"><a href="#section5">QUIRK OPTIONS</a></span>.</p>
<p>The constituents are returned as slices of the argument <i class="arg">url</i>, without removal of percent-encoding (&quot;url-encoding&quot;) or other adaptations.  Notably, on Windows&reg; the <b class="const">path</b> in scheme <i class="term"><a href="../../../../index.html#file">file</a></i> is not a valid local filename.  See <span class="sectref"><a href="#section6">EXAMPLES</a></span> for more information.</p></dd>
<dt><a name="3"><b class="cmd">uri::join</b> <span class="opt">?<i class="arg">key</i> <i class="arg">value</i>?</span>...</a></dt>
<dd><p><b class="cmd">uri::join</b> takes a list of key/value pairs (generated by
<b class="cmd">uri::split</b>, for example) and returns the canonical URL they
represent. Currently the schemes <i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>,
<i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, <i class="term"><a href="../../../../index.html#mailto">mailto</a></i>, <i class="term"><a href="../../../../index.html#news">news</a></i>, <i class="term"><a href="../../../../index.html#ldap">ldap</a></i>, <i class="term">ldaps</i> and <i class="term"><a href="../../../../index.html#file">file</a></i>
are supported by the package itself. See section <span class="sectref"><a href="#section4">EXTENDING</a></span> on how to expand that range.</p>
<p>The arguments are expected to be slices of a valid URL, with percent-encoding (&quot;url-encoding&quot;) and any other necessary adaptations.  Notably, on Windows the <b class="const">path</b> in scheme <i class="term"><a href="../../../../index.html#file">file</a></i> is not a valid local filename.  See <span class="sectref"><a href="#section6">EXAMPLES</a></span> for more information.</p></dd>
<dt><a name="4"><b class="cmd">uri::resolve</b> <i class="arg">base</i> <i class="arg">url</i></a></dt>
<dd><p><b class="cmd">uri::resolve</b> resolves the specified <i class="arg">url</i> relative to
<i class="arg">base</i>, in conformance with RFC 3986. In other words: a
non-relative <i class="arg">url</i> is returned
unchanged, whereas for a relative <i class="arg">url</i> the missing parts are
taken from <i class="arg">base</i> and prepended to it. The result of this
operation is returned. For an empty <i class="arg">url</i> the result is
<i class="arg">base</i>, without its URI fragment (if any).  The command is available for schemes <i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, and <i class="term"><a href="../../../../index.html#file">file</a></i>.</p></dd>
<dt><a name="5"><b class="cmd">uri::isrelative</b> <i class="arg">url</i></a></dt>
<dd><p><b class="cmd">uri::isrelative</b> determines whether the specified <i class="arg">url</i> is
absolute or relative.  The command is available for a <i class="arg">url</i> of any scheme.</p></dd>
<dt><a name="6"><b class="cmd">uri::geturl</b> <i class="arg">url</i> <span class="opt">?<i class="arg">options</i>...?</span></a></dt>
<dd><p><b class="cmd">uri::geturl</b> decodes the specified <i class="arg">url</i> and then dispatches
the request to the package appropriate for the scheme found in the
URL. The command assumes that the package to handle the given scheme
either has the same name as the scheme itself (including possible
capitalization) followed by <b class="cmd">::geturl</b>, or, in case of this
failing, has the same name as the scheme itself (including possible
capitalization). It further assumes that whatever package was loaded
provides a <b class="cmd">geturl</b>-command in the namespace of the same name as
the package itself. This command is called with the given <i class="arg">url</i>
and all given <i class="arg">options</i>. Currently <b class="cmd">geturl</b> does not handle
any options itself.</p>
<p><em>Note:</em> <i class="term"><a href="../../../../index.html#file">file</a></i>-URLs are an exception to the rule
described above. They are handled internally.</p>
<p>It is not possible to specify results of the command. They depend on
the <b class="cmd">geturl</b>-command for the scheme the request was dispatched to.</p></dd>
<dt><a name="7"><b class="cmd">uri::canonicalize</b> <i class="arg">uri</i></a></dt>
<dd><p><b class="cmd">uri::canonicalize</b> returns the canonical form of a URI.  The
canonical form of a URI is one where relative path specifications,
i.e. &quot;.&quot; and &quot;..&quot;, have been resolved.  The command is available for all
URI schemes that have <b class="cmd">uri::split</b> and <b class="cmd">uri::join</b> commands. The command
returns a canonicalized URI if the URI scheme has a <b class="const">path</b> component (i.e. <i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, and <i class="term"><a href="../../../../index.html#file">file</a></i>).  For schemes that have <b class="cmd">uri::split</b> and <b class="cmd">uri::join</b> commands but no <b class="const">path</b> component (i.e. <i class="term"><a href="../../../../index.html#mailto">mailto</a></i>, <i class="term"><a href="../../../../index.html#news">news</a></i>, <i class="term"><a href="../../../../index.html#ldap">ldap</a></i>, and <i class="term">ldaps</i>), the command returns the <i class="arg">uri</i> unchanged.</p></dd>
<dt><a name="8"><b class="cmd">uri::register</b> <i class="arg">schemeList</i> <i class="arg">script</i></a></dt>
<dd><p><b class="cmd">uri::register</b> registers the first element of <i class="arg">schemeList</i> as
a new scheme and the remaining elements as aliases for this scheme. It
creates the namespace for the scheme and executes the <i class="arg">script</i> in
the new namespace. The script has to declare variables containing
regular expressions relevant to the scheme. At least the variable
<b class="variable">schemepart</b> has to be declared as that one is used to extend
the variables keeping track of the registered schemes.</p></dd>
</dl>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">SCHEMES</a></h2>
<p>In addition to the commands mentioned above this package provides
regular expression to recognize URLs for a number of URL schemes.</p>
<p>For each supported scheme a namespace of the same name as the scheme
itself is provided inside of the namespace <em>uri</em> containing the
variable <b class="variable">url</b> whose contents are a regular expression to
recognize URLs of that scheme. Additional variables may contain
regular expressions for parts of URLs for that scheme.</p>
<p>The variable <b class="variable">uri::schemes</b> contains a list of all registered
schemes. Currently these are <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, <i class="term"><a href="../../../../index.html#ldap">ldap</a></i>, <i class="term">ldaps</i>, <i class="term"><a href="../../../../index.html#file">file</a></i>,
<i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, <i class="term"><a href="../../../../index.html#gopher">gopher</a></i>, <i class="term"><a href="../../../../index.html#mailto">mailto</a></i>, <i class="term"><a href="../../../../index.html#news">news</a></i>,
<i class="term"><a href="../../../../index.html#wais">wais</a></i> and <i class="term"><a href="../../../../index.html#prospero">prospero</a></i>.</p>
</div>
<div id="section4" class="doctools_section"><h2><a name="section4">EXTENDING</a></h2>
<p>Extending the range of schemes supported by <b class="cmd">uri::split</b> and
<b class="cmd">uri::join</b> is easy because both commands do not handle the
request by themselves but dispatch it to another command in the
<em>uri</em> namespace using the scheme of the URL as criterion.</p>
<p><b class="cmd">uri::split</b> and <b class="cmd">uri::join</b>
call <b class="cmd">Split[string totitle &lt;scheme&gt;]</b>
and  <b class="cmd">Join[string totitle &lt;scheme&gt;]</b> respectively.</p>
<p>The provision of split and join commands is sufficient to extend the commands <b class="cmd">uri::canonicalize</b> and <b class="cmd">uri::geturl</b>
(the latter subject to the availability of a suitable package with a <b class="cmd">geturl</b> command).  In contrast, to extend the command <b class="cmd">uri::resolve</b> to a new scheme, the command itself must be modified.</p>
<p>To extend the range of schemes for which pattern information is
available, use the command <b class="cmd">uri::register</b>.</p>
<p>An example of a package that provides both commands and pattern information for a new scheme is <b class="package">uri::urn</b>, which adds scheme <i class="term"><a href="../../../../index.html#urn">urn</a></i>.</p>
</div>
<div id="section5" class="doctools_section"><h2><a name="section5">QUIRK OPTIONS</a></h2>
<p>The value of a &quot;quirk option&quot; is boolean: the value <b class="const">false</b> requests conformance with RFC 3986, while <b class="const">true</b> requests use of the quirk.  Use command <b class="cmd">uri::setQuirkOption</b> to access the values of quirk options.</p>
<p>Quirk options are useful both for allowing backwards compatibility when a command
specification changes, and for adding useful features that are not included
in RFC specifications.  The following quirk options are currently defined:</p>
<dl class="doctools_definitions">
<dt><em>NoInitialSlash</em></dt>
<dd><p>This quirk option concerns the leading character of <b class="const">path</b> (if non-empty) in the schemes <i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, and <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>.</p>
<p>RFC 3986 defines <b class="const">path</b> in an absolute URI to have an initial &quot;/&quot;, unless the value of <b class="const">path</b> is the empty string. For the scheme <i class="term"><a href="../../../../index.html#file">file</a></i>, all versions of package <b class="package">uri</b> follow this rule.  The quirk option <em>NoInitialSlash</em> does not apply to scheme <i class="term"><a href="../../../../index.html#file">file</a></i>.</p>
<p>For the schemes <i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, and <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, versions of <b class="package">uri</b> before 1.2.7 define the <b class="const">path</b> <em>NOT</em> to include an initial &quot;/&quot;.  When the quirk option <em>NoInitialSlash</em> is <b class="const">true</b> (the default), this behavior is also used in version 1.2.7.  To use instead values of <b class="const">path</b> as defined by RFC 3986, set this quirk option to <b class="const">false</b>.</p>
<p>This setting does not affect RFC 3986 conformance.  If <em>NoInitialSlash</em> is <b class="const">true</b>, then the value of <b class="const">path</b> in the schemes <i class="term"><a href="../../../../index.html#http">http</a></i>, <i class="term"><a href="../../../../index.html#https">https</a></i>, or <i class="term"><a href="../../../../index.html#ftp">ftp</a></i>, cannot distinguish between URIs in which the full &quot;RFC 3986 path&quot; is the empty string &quot;&quot; or a single slash &quot;/&quot; respectively.  The missing information is recorded in an additional <b class="cmd">uri::split</b> key <b class="const">pbare</b>.</p>
<p>The boolean <b class="const">pbare</b> is defined when quirk options <em>NoInitialSlash</em> and <em>NoExtraKeys</em> have values <b class="const">true</b> and <b class="const">false</b> respectively.  In this case, if the value of <b class="const">path</b> is the empty string &quot;&quot;, <b class="const">pbare</b> is <b class="const">true</b> if the full &quot;RFC 3986 path&quot; is &quot;&quot;, and <b class="const">pbare</b> is <b class="const">false</b> if the full &quot;RFC 3986 path&quot; is &quot;/&quot;.</p>
<p>Using this quirk option <em>NoInitialSlash</em> is a matter of preference.</p></dd>
<dt><em>NoExtraKeys</em></dt>
<dd><p>This quirk option permits full backward compatibility with versions of <b class="package">uri</b> before 1.2.7, by omitting the <b class="cmd">uri::split</b> key <b class="const">pbare</b> described above (see quirk option <em>NoInitialSlash</em>).  The outcome is greater backward compatibility of the <b class="cmd">uri::split</b> command, but an inability to distinguish between URIs in which the full &quot;RFC 3986 path&quot; is the empty string &quot;&quot; or a single slash &quot;/&quot; respectively - i.e. a minor non-conformance with RFC 3986.</p>
<p>If the quirk option <em>NoExtraKeys</em> is <b class="const">false</b> (the default), command <b class="cmd">uri::split</b> returns an additional key <b class="const">pbare</b>, and the commands comply with RFC 3986. If the quirk option <em>NoExtraKeys</em> is <b class="const">true</b>, the key <b class="const">pbare</b> is not defined and there is not full conformance with RFC 3986.</p>
<p>Using the quirk option <em>NoExtraKeys</em> is <em>NOT</em> recommended, because if set to <b class="const">true</b> it will reduce conformance with RFC 3986.  The option is included only for compatibility with code, written for earlier versions of <b class="package">uri</b>, that needs values of <b class="const">path</b> without a leading &quot;/&quot;, <em>AND ALSO</em> cannot tolerate unexpected keys in the results of <b class="cmd">uri::split</b>.</p></dd>
<dt><em>HostAsDriveLetter</em></dt>
<dd><p>When handling the scheme <i class="term"><a href="../../../../index.html#file">file</a></i> on the
Windows platform, versions of <b class="package">uri</b> before 1.2.7
use the <b class="const">host</b> field to represent a Windows drive letter and the colon that follows it, and the <b class="const">path</b> field to represent the filename path after the colon.  Such URIs are invalid, and are not recognized by any RFC. When the quirk option <em>HostAsDriveLetter</em> is <b class="const">true</b>, this behavior is also used in version 1.2.7.  To use <i class="term"><a href="../../../../index.html#file">file</a></i> URIs on Windows that conform to RFC 3986, set this quirk option to <b class="const">false</b> (the default).</p>
<p>Using this quirk is <em>NOT</em> recommended, because if set to <b class="const">true</b> it will cause the <b class="package">uri</b> commands to expect and produce invalid URIs.  The option is included only for compatibility with legacy code.</p></dd>
<dt><em>RemoveDoubleSlashes</em></dt>
<dd><p>When a URI is canonicalized by <b class="cmd">uri::canonicalize</b>, its <b class="const">path</b> is normalized by removal of segments &quot;.&quot; and &quot;..&quot;.  RFC 3986 does not mandate
the removal of empty segments &quot;&quot; (i.e. the merger of double slashes, which is a feature of filename normalization but not of URI <b class="const">path</b> normalization): it treats URIs with excess slashes as referring to different resources.  When the quirk option <em>RemoveDoubleSlashes</em> is <b class="const">true</b> (the default), empty segments will be removed from <b class="const">path</b>.  To prevent removal, and thereby conform to RFC 3986, set this quirk option to <b class="const">false</b>.</p>
<p>Using this quirk is a matter of preference.  A URI with double slashes in its path was most likely generated by error, certainly so if it has a straightforward mapping to a file on a server.  In some cases it may be better to sanitize the URI; in others, to keep the URI and let the server handle the possible error.</p></dd>
</dl>
<div id="subsection1" class="doctools_subsection"><h3><a name="subsection1">BACKWARD COMPATIBILITY</a></h3>
<p>To behave as similarly as possible to versions of <b class="package">uri</b> earlier than 1.2.7, set the following quirk options:</p>
<ul class="doctools_itemized">
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoInitialSlash</i> 1</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoExtraKeys</i> 1</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">HostAsDriveLetter</i> 1</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">RemoveDoubleSlashes</i> 0</p></li>
</ul>
<p>In code that can tolerate the return by <b class="cmd">uri::split</b> of an additional key <b class="const">pbare</b>, set</p>
<ul class="doctools_itemized">
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoExtraKeys</i> 0</p></li>
</ul>
<p>in order to achieve greater compliance with RFC 3986.</p>
</div>
<div id="subsection2" class="doctools_subsection"><h3><a name="subsection2">NEW DESIGNS</a></h3>
<p>For new projects, the following settings are recommended:</p>
<ul class="doctools_itemized">
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoInitialSlash</i> 0</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoExtraKeys</i> 0</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">HostAsDriveLetter</i> 0</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">RemoveDoubleSlashes</i> 0|1</p></li>
</ul>
</div>
<div id="subsection3" class="doctools_subsection"><h3><a name="subsection3">DEFAULT VALUES</a></h3>
<p>The default values for package <b class="package">uri</b> version 1.2.7 are intended to be a compromise between backwards compatibility and improved features.  Different default values may be chosen in future versions of package <b class="package">uri</b>.</p>
<ul class="doctools_itemized">
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoInitialSlash</i> 1</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">NoExtraKeys</i> 0</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">HostAsDriveLetter</i> 0</p></li>
<li><p><b class="cmd">uri::setQuirkOption</b> <i class="arg">RemoveDoubleSlashes</i> 1</p></li>
</ul>
</div>
</div>
<div id="section6" class="doctools_section"><h2><a name="section6">EXAMPLES</a></h2>
<p>A Windows&reg; local filename such as &quot;<b class="const">C:\Other Files\startup.txt</b>&quot; is not suitable for use as the <b class="const">path</b> element of a URI in the scheme <i class="term"><a href="../../../../index.html#file">file</a></i>.</p>
<p>The Tcl command <b class="cmd">file normalize</b> will convert the backslashes to forward slashes.  To generate a valid <b class="const">path</b> for the scheme <i class="term"><a href="../../../../index.html#file">file</a></i>, the normalized filename must be prepended with &quot;<b class="const">/</b>&quot;, and then any characters that do not match the <b class="cmd">regexp</b> bracket expression</p>
<pre class="doctools_example">
    [a-zA-Z0-9$_.+!*'(,)?:@&amp;=-]
</pre>
<p>must be percent-encoded.</p>
<p>The result in this example is &quot;<b class="const">/C:/Other%20Files/startup.txt</b>&quot; which is a valid value for <b class="const">path</b>.</p>
<pre class="doctools_example">
% uri::join path /C:/Other%20Files/startup.txt scheme file
file:///C:/Other%20Files/startup.txt
% uri::split file:///C:/Other%20Files/startup.txt
path /C:/Other%20Files/startup.txt scheme file
</pre>
<p>On UNIX&reg; systems filenames begin with &quot;<b class="const">/</b>&quot; which is also used as the directory separator.  The only action needed to convert a filename to a valid <b class="const">path</b> is percent-encoding.</p>
</div>
<div id="section7" class="doctools_section"><h2><a name="section7">CREDITS</a></h2>
<p>Original code (regular expressions) by Andreas Kupries.
Modularisation by Steve Ball, also the split/join/resolve
functionality. RFC 3986 conformance by Keith Nash.</p>
</div>
<div id="section8" class="doctools_section"><h2><a name="section8">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>uri</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#fetching_information">fetching information</a>, <a href="../../../../index.html#file">file</a>, <a href="../../../../index.html#ftp">ftp</a>, <a href="../../../../index.html#gopher">gopher</a>, <a href="../../../../index.html#http">http</a>, <a href="../../../../index.html#https">https</a>, <a href="../../../../index.html#ldap">ldap</a>, <a href="../../../../index.html#mailto">mailto</a>, <a href="../../../../index.html#news">news</a>, <a href="../../../../index.html#prospero">prospero</a>, <a href="../../../../index.html#rfc_1630">rfc 1630</a>, <a href="../../../../index.html#rfc_2255">rfc 2255</a>, <a href="../../../../index.html#rfc_2396">rfc 2396</a>, <a href="../../../../index.html#rfc_3986">rfc 3986</a>, <a href="../../../../index.html#uri">uri</a>, <a href="../../../../index.html#url">url</a>, <a href="../../../../index.html#wais">wais</a>, <a href="../../../../index.html#www">www</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>Networking</p>
</div>
</div></body></html>
